<template>
	<!-- 慕再风险筛查 -->
	<!-- 待处理事项模块-影像列表 -->
	<div class="fillcontain">
		<el-dialog title="iRisk" :visible.sync="drawer" :width="'50%'" :before-close="handleClose" center>
			<!-- <div class="contain"> -->
			<!-- 表格 -->
			<div class="contain">
				<el-row class="mt10">
					<el-col :span="8">
						<button class="check-info " @click="callMz()">发起iRisk调用</button>
					</el-col>
				</el-row>
				<div style="height: 50%;overflow-y: auto;">
					<el-row class="mt10" style="border-top: 1px solid #e1e1e1 !important;">
						<el-form label-width="100px" class="search_container">
							<el-row>

								<el-col :span="12" class="common-box">
									<el-form-item label="风险等级">
										<span>{{mz.RiskLevel}}</span>
									</el-form-item>
								</el-col>
								<el-col :span="12" class="common-box">
									<el-form-item label="风险评分">
										<span>{{mz.RiskScore}}</span>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12" class="common-box">
									<el-form-item label="风险说明">
										<span>{{mz.RiskDesc}}</span>
									</el-form-item>
								</el-col>
								<el-col :span="12" class="common-box">
									<el-form-item label="核保结论">
										<span>{{mz.DecisionValue}}</span>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row>
								<el-col :span="12" class="common-box">
									<el-form-item label="核保结论说明">
										<span>{{mz.DecisionDesc}}</span>
									</el-form-item>
								</el-col>
							</el-row>
							<el-row v-for="item in mz.Exts" class="mt10"
								style="border-top: 1px solid #e1e1e1 !important;">
								<el-col :span="12" class="common-box">
									<el-form-item label="附加信息编码">
										<span>{{item.ExtCode}}</span>
									</el-form-item>
								</el-col>
								<el-col :span="12" class="common-box">
									<el-form-item label="附件信息名称">
										<span>{{item.ExtName}}</span>
									</el-form-item>
								</el-col>
								<el-col :span="12" class="common-box">
									<el-form-item label="附加信息值">
										<span>{{item.ExtValue}}</span>
									</el-form-item>
								</el-col>
							</el-row>
						</el-form>
					</el-row>
				</div>

			</div>
		</el-dialog>
	</div>
</template>
<script>
	import moment from 'moment';
	import constant from '@/utils/constant';
	import TaskConstants, {
		call
	} from "@/api/taskManager/common";
	export default {
		data() {
			return {
				mz: {
					"RiskLevel": '',
					"RiskScore": '',
					"RiskDesc": "",
					"DecisionValue": "",
					"DecisionDesc": "",
					"Exts": [],
				},
				emptyMz: '', //缓存空的
      }
		},
		props: {
			drawer: {
				type: Boolean,
				default: false
			},
			item: {
				type: Object,
				default: {}
			},
		},
		watch: {
			item: function(newValue) {
				if(undefined != newValue){
					this.callMz();
				}
			}
		},
		created() {
			this.emptyMz = JSON.parse(JSON.stringify(this.mz));
		},
		methods: {
			show() {
				this.$store.dispatch('loading/CHANGE_LOADING', true);
			},
			cancle() {
				this.$store.dispatch('loading/CHANGE_LOADING', false)
			},
			handleClose(done) {
			  this.$emit('close', this.drawer);
			},
			callMz() {
				let body ={
					"type": "ciitc_irisk",
					 "sysFrom": "S10009",
					 "queryFlag": "Y",
					 "userCode": "citic",
					 "userName": "统一核保平台",
					 "datetime": moment().format('YYYYMMDD HH:mm:ss'),
					 "swiftNumber": moment().format('YYYYMMDDHHmmsssSSSSSSSSS'),
				}
				let params = {
					"ciitc_irisk":{
						"RiskType": this.item.riskType,
						"PolicyCode": this.item.policyNo,
						"PartyCode": this.item.clntnum,
						"Name": this.item.name,
						"CredNumber": this.item.cardNum,
						"Gender": this.item.sex,
						"Birthday": this.item.birthday,
						"Mobile": this.item.mobile,
						"EffectiveTime": this.item.EffectiveTime,
						"AmtSa": this.item.AmtSa,
						"InsureProvince": this.item.InsureProvince,
						"Scoure":'ILMP'
					}
				};
				body['reqBody'] = params;
				//清空之前的
				this.mz = JSON.parse(JSON.stringify(this.emptyMz));
				let that = this;
				that.show();
				call(TaskConstants.apis.mzQuery, body, "post").then(result => {
					if (result.resultCode == constant.SUCCESS && result.data && result.data.length>0) {
						let data = result.data[0]['ciitc_irisk'];
						Object.keys(this.mz).forEach(function(key, index) {
							let v = data[key]
							if(key == 'DecisionDesc' ){
								let d = v.substring(v.length-1);
								if ( d ==',') {
									v= v.substring(0,v.length -1);
								}
							}
              // 映射Paypower_Fore_Grade的value值 --lvjg 20211222
              if (key == "Exts") {
                v.map((item) => {
                  if (item.ExtCode == "Paypower_Fore_Grade") {
                    let value = item.ExtValue;
                    if (value == "1") {
                      item.ExtValue = "近一年收入10万及未查得";
                    } else if (value == "2") {
                      item.ExtValue = "近一年收入10万（含）-40万";
                    }else if (value == "3") {
                      item.ExtValue = "近一年收入40万（含）-60万";
                    }else if (value == "4") {
                      item.ExtValue = "近一年收入 60万（含）-100万";
                    }else if (value == "5") {
                      item.ExtValue = "近一年收入100万以上";
                    }
                  }
                });
              }
              that.mz[key] = v;
						})
					}
					that.cancle();
				})
			}
		}
	}
</script>
<style lang="less" scoped>
	.fillcontain {
		padding-bottom: 0;
	}

	.contain {
		background: #fff;
		// padding: 10px;
		margin-bottom: 20px;
	}

	.pagination {
		padding: 10px 20px;
		text-align: right;
	}

	.operationIcon {
		// padding: 12px;
		border: 1px solid #e5e5e5;
		border-radius: 50%;
		width: 22px;
		height: 22px;
		display: inline-block;
		cursor: pointer;
		box-shadow: 0 0 3px #f9f9f9;

		.svg-icon {
			font-size: 14px;
			fill: #68a3fc;
		}
	}

	.search_container {
		padding: 20px 20px 0 20px;
		// border-top: 1px solid #e1e1e1;
	}
</style>
